<template>
  <div class="content">
    <div class="tableBox posting_box_list">
      <el-table :data="tableData" stripe style="width: 100%" v-loading="loading" border>
        <template v-for="(item,index) in allData">
          <el-table-column
            :key="index"
            v-if="item.value=='name'"
            :label="item.label"
            align="center"
          >
            <template slot-scope="scope">
              <span
                @click="handleClickNickName(scope.row)"
                style="color: #6b97eb;cursor: pointer;"
              >{{scope.row.name}}</span>
            </template>
          </el-table-column>
          <el-table-column
            :key="index"
            :prop="item.value"
            v-if="item.value!=='opt' && item.value!='name' && item.value!='companyname'"
            :label="item.label"
            align="center"
          ></el-table-column>
          <el-table-column
            :key="index"
            v-if="item.value=='companyname'"
            :label="item.label"
            align="center"
          >
            <template slot-scope="scope">
              <span
                @click="handleClickCompanyName(scope.row)"
                style="color: #6b97eb;cursor: pointer;"
              >{{scope.row.companyname}}</span>
            </template>
          </el-table-column>
          <el-table-column
            :key="item.value"
            v-else-if="item.value=='opt'"
            label="操作"
            min-width="100px"
            align="center"
          >
            <template slot-scope="scope">
              <el-button @click="lookLog(scope.row)" type="text" size="small">查看日志</el-button>
              <el-button
                @click="handleAabnormal(scope.row)"
                type="text"
                size="small"
                v-show="global.powerAllBtn.yccl.qnlzclBtn"
              >处理</el-button>
              <!-- <el-button v-show="scope.row.remark === '1'" type="text" size="small" @click="remove(scope.row)">下架</el-button> -->
              <el-button
                type="text"
                size="small"
                @click="handleReport(scope.row)"
                v-show="global.powerAllBtn.yccl.qnlzsbBtn"
              >上报</el-button>
            </template>
          </el-table-column>
        </template>
      </el-table>
    </div>
    <div style="padding:20px 0">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="ScheduleCurrentChange"
        :current-page="pages.pagenum"
        :page-sizes="[10,20, 30, 50,100]"
        :page-size="pages.pagesize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="pages.total"
        background
      ></el-pagination>
    </div>
    <el-dialog :visible.sync="dialogVisible" width="500px">
      <div class="abnormal-dialog-header">
        <span>处理</span>
      </div>
      <div class="abnormal-handle-box">
        <el-row class="abnormal-handle-row">
          <el-col :span="12">
            <el-radio v-model="params.status" label="21">在职</el-radio>
            <el-radio v-model="params.status" label="11">离职</el-radio>
          </el-col>
        </el-row>
        <el-row class="abnormal-handle-row">
          <el-col :span="16">
            <el-input v-model="params.note" placeholder="备注："></el-input>
          </el-col>
        </el-row>
        <div class="abnormal-dialog-btn">
          <el-button class="cancel-btn" @click="dialogVisible = false">取消</el-button>
          <el-button class="sure-btn" type="primary" @click="submit">确定</el-button>
        </div>
      </div>
    </el-dialog>
    <el-dialog :visible.sync="warnDialogVisible" width="500px" @close="closeWarnDialog">
      <div class="warn-dialog-header">
        <span>上报原因</span>
      </div>
      <div class="warn-dialog-body">
        <div class="warn-dialog-body-title">发送内容</div>
        <el-input type="textarea" :rows="6" v-model.trim="reportContent"></el-input>
        <div class="warn-dialog-btn">
          <el-button style="margin-right: 30px;" @click="warnDialogVisible = false">取消</el-button>
          <el-button type="primary" @click="confirmReport">确定</el-button>
        </div>
      </div>
    </el-dialog>
    <el-dialog :visible.sync="showLog" width="1024px" custom-class="showlog">
      <showLog :reportid="reportId"></showLog>
    </el-dialog>

    <el-dialog :visible.sync="dialoghyVisible" width="1040px">
      <resume-detail
        v-if="dialoghyVisible"
        :userid="userid"
        :nickName="nickName"
        :isShowTelphone="true"
      ></resume-detail>
    </el-dialog>
    <el-dialog :visible.sync="dialogVisible2" width="1040px">
      <company-detail
        v-if="dialogVisible2"
        :companyName="companyname"
        :companyId="companyid"
        :type="'0'"
        :tabNum="'4'"
      ></company-detail>
    </el-dialog>
  </div>
</template>
<script>
import showLog from "../showLog.vue";
import resumeDetail from "../../../component/resumeDetail/index.vue";
// import companyDetail from '../../../component/companyDetail/index.vue';
import companyDetail from "../../socical/socialCheck/check.vue";
export default {
  data () {
    return {
      tableData: [],
      loading: false,
      allData: [],
      pages: {
        pagesize: 10,
        total: 0,
        pagenum: 1,
      },
      dialogVisible: false,
      abnormaldetail: {},
      warnDialogVisible: false,//上报弹窗
      reportContent: '',//上报原因
      companyType: '',//上报type
      reportId: '',//上报id
      reportStatus: "",
      params: {
        employeeid: "",
        status: '21',
        note: ""
      },
      showLog: false,
      dialoghyVisible: false,
      userid: '',
      nickName: '',
      dialogVisible2: false,
      companyid: '',
      companyname: ''

    }
  },
  props: ['type'],
  components: {
    showLog,
    resumeDetail,
    companyDetail
  },
  created () {
    this.allData = [{
      label: "会员名称",
      value: "name"
    }, {
      label: "手机号码",
      value: "telnum"
    },
    {
      label: "录取企业名称",
      value: "companyname"
    },
    {
      label: "个人状态",
      value: "personalstatus"
    }, {
      label: "企业状态",
      value: "companystatus"
    },
    {
      label: "入职时间",
      value: "entrydate"
    },
    {
      label: "离职时间",
      value: "offdate"
    },
    {
      label: "操作",
      value: "opt"
    }
    ]
    this.global = this.GLOBAL;
    this.getData();
  },
  methods: {
    //获取列表
    getData () {
      if (!this.type) {
        return;
      }
      this.loading = true;
      let obj = {
        pagenum: this.pages.pagesize,
      }
      this.$axios.post('/app/v1/platform/unusual/todoList', {
        "type": this.type,
        pagesize: this.pages.pagesize,
        pagenum: this.pages.pagenum
      }).then(resp => {
        if (resp.data.message === 'success.') {
          this.tableData = resp.data.data.list;
          this.pages.total = Number(resp.data.data.totalnum);
          this.pages.pagesize = Number(resp.data.data.pagesize);
          this.loading = false;

        }
      })
    },

    // 处理异常
    handleAabnormal (row) {
      this.params.employeeid = row.id;
      this.reportId = row.reportid;
      this.dialogVisible = true;
    },
    submit () {
      this.$confirm('此操作将处理该异常, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$axios.post("/app/v1/platform/abnormal/employeeResult", this.params).then(res => {
          if (res.data.message === 'success.') {
            this.$message({
              message: "处理成功!",
              type: "success"
            });

            // let currentData = {
            //   reportid: this.reportId,
            //   status: 1,
            //   content: '保障内离职异常处理成功'
            // }
            // this.reportCall(currentData)

          } else {
            this.$message({
              message: res.data.message,
              type: "error"
            });
          }
          this.dialogVisible = false;
          this.getData();
        })
      }).catch(() => {
        console.log('已取消删除');
      });
    },
    closeDialog () {
      this.abnormaldetail = {};
      this.params.reviewid = "";
      this.params.checked = false;
      this.params.note = "";
    },
    close () {
      this.checkFlag = false;
      this.getData(this.companyType);
    },
    // 查看会员详情
    handleClickNickName (row) {
      this.userid = row.userid;
      this.nickName = row.name;
      this.dialoghyVisible = true;
    },
    // 查看公司详情
    handleClickCompanyName (row) {
      this.companyid = row.companyid;
      this.companyname = row.companyname;
      this.dialogVisible2 = true;
    },
    handleSizeChange (val) {
      this.pages.pagenum = 1;
      this.pages.pagesize = val;
      this.getData();
    },
    //分页查询
    ScheduleCurrentChange (val) {
      this.pages.pagenum = val;
      this.getData();
    },
    handleReport (row) {
      this.reportId = row.reportid;
      this.reportContent = '';
      this.warnDialogVisible = true;
    },
    //上报里确定
    confirmReport () {
      if (!this.reportContent) {
        this.$message({
          type: "warning",
          message: "上报内容不能为空!"
        });
        return;
      }
      let currentData = {
        reportid: this.reportId,
        status: 0,
        content: this.reportContent || ''
      }
      this.reportCall(currentData)
    },
    //待办提交
    reportCall (data) {
      this.$axios.post('app/v1/platform/unusual/todoHandleSubmit',
        data
      ).then(resp => {
        if (resp.data.message === 'success.') {
          this.warnDialogVisible = false;
          // this.tableData = resp.data.data;
          // this.pages.total = resp.data.data.length;
          this.loading = false;
          this.getData();
        } else {
          this.warnDialogVisible = false;
          this.$message({
            message: resp.data.message,
            type: "error"
          });
        }
      })

    },
    reportCallback (currentData) {
      var data = {
        reportid: this.reportId,
        status: currentData.status,
        content: currentData.content || ''
      }
      this.$emit('reportCallback', data)
    },
    closeWarnDialog () {
      this.reportContent = "";
    },
    lookLog (row) {
      this.reportId = row.reportid;
      this.showLog = true;
    }
  },


}
</script>
<style>
.abnormal-dialog-header {
  font-size: 16px;
  box-sizing: border-box;
  padding: 20px;
  border-bottom: 1px solid #e4e4e4;
}

.abnormal-dialog-header::before {
  content: "";
  border-left: 10px solid #0064e4;
  margin-right: 10px;
}

.abnormal-detail-box {
  box-sizing: border-box;
  padding: 20px;
  border-bottom: 1px dashed #e4e4e4;
}

.abnormal-detail-title,
.abnormal-handle-title {
  font-size: 16px;
  margin-bottom: 20px;
}

.abnormal-detail-row,
.abnormal-handle-row {
  color: #ababab;
  font-size: 15px;
  box-sizing: border-box;
  padding-left: 20px;
  padding-right: 20px;
  margin-bottom: 20px;
}

.abnormal-detail-box .abnormal-detail-row:nth-last-of-type(1) {
  margin-bottom: 0;
}

.col-name {
  color: #ababab;
}

.col-value {
  color: #404040;
}

.abnormal-handle-box {
  box-sizing: border-box;
  padding: 20px;
}

.abnormal-dialog-btn {
  margin-top: 20px;
  text-align: center;
}

.cancel-btn {
  width: 120px;
  margin-right: 30px;
}

.sure-btn {
  width: 120px;
}

/* 上报原因样式 */
.warn-dialog-header {
  font-size: 16px;
  box-sizing: border-box;
  padding: 20px;
  border-bottom: 1px solid #bfbfbf;
}

.warn-dialog-header::before {
  content: "";
  border-left: 8px solid #0064e4;
  margin-right: 10px;
}

.warn-dialog-body {
  box-sizing: border-box;
  padding: 20px;
}

.warn-dialog-body-title {
  font-size: 16px;
  margin-bottom: 20px;
}

.warn-dialog-btn {
  margin-top: 20px;
  text-align: center;
}
</style>









